package nan.object_oriented;

class Animal2 {
    protected String name;
    public Animal2(String name) {//构造方法
        this.name = name;
    }
}
interface IFlying {//接口IFlying
    void fly();
}
interface IRunning {//接口IRunning
    void run();
}
interface ISwimming {//接口ISwimming
    void swim();
}
//拿到动物的普遍属性，并且用了接口IRunning（特有属性）
class Cat1 extends Animal2 implements IRunning {//继承Animal2实现IRunning接口
    public Cat1(String name) {//调用Animal2的构造方法
        super(name);
    }
    @Override
    public void run() {
        System.out.println(this.name + "正在用四条腿跑");
    }
}

public class Main4 {
    public static void walk(IRunning iRunning){
        iRunning.run();//多态
    }
    public static void main(String[] args) {
        IRunning iRunning=new Cat1("mimi");
        walk(iRunning);
    }
}
